package com.fxb.stream.demo1;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 演示Stream流操作
 *
 * @author fangjiaxiaobai
 * @date 2021-08-20 15:55
 */
public class StreamDemo1 {

    public static void main(String[] args) {
        List<Integer> numbers = Stream.of(1, 2, 3, 4)
                .map(item -> item + 5)
                .sorted((n1, n2) -> n2 - n1)
                .limit(3)
                .collect(Collectors.toList());
        numbers.forEach(System.out::println);
        System.out.println(numbers);
    }
}
